//直接封装成组件
//将内容直接封装成了组件

import React, { FC } from "react";
import { QuestParagraphPropsType, QuestionParagraphDefaultProps } from "./interface";
import { Typography } from "antd";

const { Paragraph } = Typography;
const QuestParagraph: FC<QuestParagraphPropsType> = (props: QuestParagraphPropsType) => {
  const { text = "", isCenter = false } = { ...QuestionParagraphDefaultProps, ...props };
  // const t = text.replaceAll("\n", "<br>");
  const textList = text.split("\n");
  return (
    <Paragraph style={{ textAlign: isCenter ? "center" : "start", marginBottom: 0 }}>
      {/* <span dangerouslySetInnerHTML={{ __html: t }}></span> */}
      {textList.map((t, index) => (
        <span key={index}>
          {index > 0 && <br />}
          {t}
        </span>
      ))}
    </Paragraph>
  );
};
export default QuestParagraph;
